export default class ImageExample {
  /**活动转发
   * title 活动标题
   * image 活动图片
   * userImg 用户头像
   * nickName 用户昵称
   * startDate 开始时间
   * endDate 结束时间
   */
  activity(title, image, userImg, nickName, startDate, endDate, codeImg) {
    const padding = 15 // 图片padding
    let imgBottomStart = 329
    let posWidth = 325 // 图片默认宽度
    let posHeight = 450 // 图片默认宽度
    let scale = 1
    return {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        {
          type: 'rect',
          background: '#ffffff',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },

        {
          type: 'image',
          url: '%ASSETS_IMG%/s-share-top1@2x.jpg',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: 69 * scale
        },
        {
          type: 'image',
          url: `${image}`,
          top: 69 * scale,
          left: 0,
          width: 325 * scale,
          height: 260 * scale
        },
        {
          type: 'text',
          content: title,
          fontSize: 14 * scale,
          color: '#000000',
          breakWord: true,
          MaxLineNumber: 2,
          width: 200 * scale,
          left: padding * scale,
          top: (imgBottomStart + 17) * scale,
          lineHeight: 18 * scale
        },
        {
          type: 'text',
          content: '限时特卖',
          fontSize: 12 * scale,
          color: '#E9415A',
          top: (imgBottomStart + 67) * scale,
          left: padding * scale
        },

        {
          type: 'rect',
          top: (imgBottomStart + 87) * scale,
          left: padding * scale,
          background: '#E9415A',
          width: 76 * scale,
          height: 19 * scale
        },
        {
          type: 'text',
          content: `${startDate}-${endDate}`,
          fontSize: 12 * scale,
          color: '#ffffff',
          top: (imgBottomStart + 89) * scale,
          left: 20 * scale
        },

        {
          type: 'image',
          url: codeImg,
          top: (imgBottomStart + 13) * scale,
          left: 233 * scale,
          width: 78 * scale,
          height: 78 * scale
        },
        {
          type: 'text',
          content: '长按二维码选购',
          fontSize: 9 * scale,
          color: '#666666',
          top: (imgBottomStart + 96) * scale,
          left: 239 * scale
        }
      ]
    }
  }
  /**商品转发
   * title 活动标题
   * image 活动图片
   * userImg 用户头像
   * nickName 用户昵称
   * startDate 开始时间
   * endDate 结束时间
   * price  商品价格
   */
  goods(params) {
    const imgBottomStart = 394 //图片top开始位置
    const padding = 15 // 图片padding
    let posWidth = 325 // 图片默认宽度
    let posHeight = 527 // 图片高度
    let scale = 1.5

    let temp = {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        {
          type: 'rect',
          background: '#ffffff',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },
        {
          type: 'image',
          url: '%ASSETS_IMG%/s-share-top1@2x.jpg',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: 69 * scale
        },
        {
          type: 'image',
          url: params.goodsImg,
          top: 69 * scale,
          left: 0,
          width: 325 * scale,
          height: 325 * scale
        },

        {
          type: 'text',
          content: `${params.goodsMoney}`,
          fontSize: 19 * scale,
          color: '#FF0000',
          textAlign: 'left',
          top: (imgBottomStart + 18) * scale,
          left: (padding + 48) * scale
        },
        // 折扣
        {
          type: 'rect',
          top: (imgBottomStart + 23) * scale,
          left: padding + 80 + params.goodsMoney.length * 11 * scale,
          background: '#FFF4F4',
          width: 36 * scale,
          height: 16 * scale,
          radius: 8 * scale
        },
        {
          type: 'text',
          content: `${params.discount} 折`,
          color: '#FF0000',
          top: (imgBottomStart + 25) * scale,
          left: padding + 86 + params.goodsMoney.length * 11 * scale,
          fontSize: 10 * scale
        },
        {
          type: 'text',
          content: `市场价: ¥${params.goodsPrice}`,
          color: '#999999',
          top: (imgBottomStart + 42) * scale,
          left: padding * scale,
          fontSize: 12 * scale,
          textDecoration: 'line-through'
        },

        {
          type: 'image',
          url: params.codeImg,
          top: (imgBottomStart + 17) * scale,
          left: 233 * scale,
          width: 77 * scale,
          height: 77 * scale
        },
        {
          type: 'text',
          content: '长按二维码选购',
          fontSize: 9 * scale,
          color: '#666666',
          top: (imgBottomStart + 103) * scale,
          left: 241 * scale
        }
      ]
    }
    // 专场商品
    if (params.startDate) {
      temp.views.push(
        {
          type: 'text',
          content: `劲爆价 ¥`,
          fontSize: 12 * scale,
          color: '#FF0000',
          textAlign: 'left',
          top: (imgBottomStart + 24) * scale,
          left: padding * scale
        },
        {
          type: 'text',
          content: params.goodsName,
          color: '#333333',
          textAlign: 'left',
          breakWord: true,
          top: (imgBottomStart + 65) * scale,
          left: padding * scale,
          fontSize: 14 * scale,
          width: 165 * scale, // 大于...
          MaxLineNumber: 1,
          lineHeight: 20 * scale,
          bolder: true
        },
        {
          type: 'rect',
          top: (imgBottomStart + 93) * scale,
          left: padding * scale,
          background: '#E9415A',
          width: 138 * scale,
          height: 20 * scale
        },
        {
          type: 'rect',
          top: (imgBottomStart + 94) * scale,
          left: (padding + 1) * scale,
          background: '#ffffff',
          width: 58 * scale,
          height: 18 * scale
        },
        {
          type: 'text',
          content: `限时特卖`,
          fontSize: 12 * scale,
          color: '#E9415A',
          top: (imgBottomStart + 96) * scale,
          left: (padding + 5) * scale
        },
        {
          type: 'text',
          content: `${params.startDate}-${params.endDate}`,
          fontSize: 12 * scale,
          color: '#ffffff',
          top: (imgBottomStart + 96) * scale,
          left: (padding + 65) * scale
        }
      )
      // 秒杀商品
    } else if (params.showTime) {
      temp.views.push(
        {
          type: 'text',
          content: `快抢价 ¥`,
          fontSize: 12 * scale,
          color: '#FF0000',
          textAlign: 'left',
          top: (imgBottomStart + 24) * scale,
          left: padding * scale
        },
        {
          type: 'text',
          content: params.goodsName,
          color: '#333333',
          textAlign: 'left',
          breakWord: true,
          top: (imgBottomStart + 65) * scale,
          left: padding * scale,
          fontSize: 14 * scale,
          width: 165 * scale, // 大于...
          MaxLineNumber: 1,
          lineHeight: 20 * scale,
          bolder: true
        },

        {
          type: 'rect',
          top: (imgBottomStart + 93) * scale,
          left: padding * scale,
          background: '#E9415A',
          width: 125 * scale,
          height: 20 * scale
        },
        {
          type: 'rect',
          top: (imgBottomStart + 94) * scale,
          left: (padding + 1) * scale,
          background: '#ffffff',
          width: 58 * scale,
          height: 18 * scale
        },
        {
          type: 'text',
          content: `限时快抢`,
          fontSize: 12 * scale,
          color: '#E9415A',
          top: (imgBottomStart + 96) * scale,
          left: (padding + 5) * scale
        },
        {
          type: 'text',
          content: `${params.showTime}`,
          fontSize: 12 * scale,
          color: '#ffffff',
          top: (imgBottomStart + 96) * scale,
          left: (padding + 65) * scale
        },
        {
          type: 'image',
          url: '%ASSETS_IMG%/s-seckill-canvas-tips@2x.png',
          top: 75 * scale,
          left: 263 * scale,
          width: 47 * scale,
          height: 51 * scale
        }
      )
    } else {
      temp.views.push(
        {
          type: 'text',
          content: `到手价 ¥`,
          fontSize: 12 * scale,
          color: '#FF0000',
          textAlign: 'left',
          top: (imgBottomStart + 24) * scale,
          left: padding * scale
        },
        {
          type: 'text',
          content: params.goodsName,
          color: '#333333',
          textAlign: 'left',
          breakWord: true,
          top: (imgBottomStart + 65) * scale,
          left: padding * scale,
          fontSize: 14 * scale,
          width: 165 * scale, // 大于...
          MaxLineNumber: 2,
          lineHeight: 20 * scale,
          bolder: true
        }
      )
    }
    return temp
  }

  /**商品转发
   * title 活动标题
   * image 活动图片
   * userImg 用户头像
   * nickName 用户昵称
   * startDate 开始时间
   * endDate 结束时间
   * price  商品价格
   */
  acgoods(title, image, userImg, nickName, startDate, endDate, money, price, discount, codeImg) {
    const imgBottomStart = 310 //图片top开始位置
    const padding = 10 // 图片padding
    let posWidth = 275 // 图片默认宽度
    let posHeight = 417 // 图片默认宽度
    let scale = 1.5
    return {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        {
          type: 'rect',
          background: '#ffffff',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },
        {
          type: 'image',
          url: '%ASSETS_IMG%/s-share-top1@2x.jpg',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: 40 * scale
        },

        {
          type: 'image',
          url: image,
          top: 55 * scale,
          left: padding * scale,
          width: 255 * scale,
          height: 255 * scale
        },
        {
          type: 'text',
          content: `¥${money}`,
          fontSize: 16 * scale,
          color: '#F96C1F',
          textAlign: 'left',
          top: (imgBottomStart + 12) * scale,
          left: padding * scale,
          bolder: true
        },
        // 折扣
        {
          type: 'rect',
          top: (imgBottomStart + 18) * scale,
          left: padding + money.length * 11 * scale,
          background: '#F96C1F',
          width: 31 * scale,
          height: 11 * scale,
          radius: 5 * scale
        },
        {
          type: 'text',
          content: `${discount} 折`,
          color: '#ffffff',
          top: (imgBottomStart + 18) * scale,
          left: padding + 6 + money.length * 11 * scale,
          fontSize: 8 * scale
        },

        {
          type: 'text',
          content: `市场价: ${price}`,
          color: '#999999',
          top: (imgBottomStart + 29) * scale,
          left: padding * scale,
          fontSize: 9 * scale,
          textDecoration: 'line-through'
        },
        {
          type: 'text',
          content: title,
          color: '#333333',
          textAlign: 'left',
          breakWord: true,
          top: (imgBottomStart + 44) * scale,
          left: padding * scale,
          fontSize: 12 * scale,
          width: 165 * scale, // 大于...
          MaxLineNumber: 1,
          bolder: true
        },
        {
          type: 'image',
          url: '%ASSETS_IMG%/s-time-bg@2x.png',
          top: (imgBottomStart + 66) * scale,
          left: padding * scale,
          width: 141 * scale,
          height: 20 * scale
        },
        {
          type: 'text',
          content: `限时特卖  ${startDate}-${endDate}`,
          fontSize: 12 * scale,
          color: '#461100',
          top: (imgBottomStart + 68) * scale,
          left: 16 * scale
        },
        {
          type: 'image',
          url: codeImg,
          top: (imgBottomStart + 7) * scale,
          left: 199 * scale,
          width: 67 * scale,
          height: 67 * scale
        },
        {
          type: 'text',
          content: '长按二维码选购',
          fontSize: 8 * scale,
          color: '#666666',
          top: (imgBottomStart + 75) * scale,
          left: 204 * scale
        }
      ]
    }
  }

  /**个人中心
   * userImg 用户头像
   * nickName 用户昵称
   * codeImg 二维码
   */
  home(userImg, nickName, codeImg) {
    const padding = 10 // 图片padding
    let posWidth = 325 // 图片默认宽度
    let posHeight = 424 // 图片默认宽度
    let scale = 1.5
    let top = 69
    return {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        {
          type: 'rect',
          background: '#ffffff',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },
        {
          type: 'image',
          url: '%ASSETS_IMG%/s-share-top1@2x.jpg',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: 69 * scale
        },
        {
          type: 'image',
          url: `${userImg}?roundPic/radius/66`,
          top: (top + 10) * scale,
          left: 147 * scale,
          width: 31 * scale,
          height: 31 * scale
        },
        // 昵称
        {
          type: 'text',
          content: nickName,
          fontSize: 11 * scale,
          color: '#999999',
          breakWord: true,
          MaxLineNumber: 1,
          textAlign: 'center',
          width: (posWidth - padding * 2) * scale,
          left: (posWidth / 2) * scale,
          top: (top + 48) * scale,
          bolder: true
        },
        {
          type: 'text',
          content: '精选推荐',
          fontSize: 14 * scale,
          color: '#333333',
          textAlign: 'left',
          top: (top + 64) * scale,
          left: 132 * scale
        },
        {
          type: 'image',
          url: codeImg,
          top: (top + 107) * scale,
          left: 86 * scale,
          width: 155 * scale,
          height: 155 * scale
        },
        {
          type: 'text',
          content: '扫描或长按识别二维码',
          fontSize: 14 * scale,
          color: '#666666',
          top: (top + 292) * scale,
          left: 94 * scale
        }
      ]
    }
  }
  /**首页分享
   * userImg 用户头像
   * nickName 用户昵称
   * codeImg 二维码
   */
  index(codeImg, shareImg) {
    const padding = 10 // 图片padding
    let posWidth = 310 // 图片默认宽度
    let posHeight = 426 // 图片默认宽度
    let scale = 1.5
    return {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        {
          type: 'rect',
          background: '#ffffff',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },
        {
          type: 'image',
          url: shareImg,
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: 310 * scale
        },
        {
          type: 'image',
          url: codeImg,
          top: 318 * scale,
          left: 120 * scale,
          width: 70 * scale,
          height: 70 * scale
        },
        {
          type: 'text',
          content: '扫描或长按识别二维码',
          fontSize: 12 * scale,
          color: '#666666',
          top: 395 * scale,
          left: 93 * scale
        }
      ]
    }
  }
  /**红包转发
   * title 活动标题
   * image 活动图片
   * userImg 用户头像
   * nickName 用户昵称
   */
  red(userImg, nickName, codeImg) {
    const padding = 10 // 图片padding
    let posWidth = 300 // 图片默认宽度
    let posHeight = 385 // 图片默认宽度
    let scale = 1.5
    return {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        //背景图
        {
          type: 'image',
          url: '%ASSETS_IMG%/s-red-bg@2x.png',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },
        {
          type: 'image',
          url: `${userImg}?roundPic/radius/66`,
          top: 15 * scale,
          left: padding * scale,
          width: 40 * scale,
          height: 40 * scale
        },
        {
          type: 'text',
          content: nickName,
          color: '#ffffff',
          top: 26 * scale,
          left: 60 * scale,
          fontSize: 16 * scale
        },
        {
          type: 'rect',
          top: 80 * scale,
          left: 38 * scale,
          background: '#ffffff',
          width: 225 * scale,
          height: 225 * scale,
          radius: 112 * scale
        },
        {
          type: 'image',
          url: `${codeImg}?roundPic/radius/${100 * scale}`,
          top: 95 * scale,
          left: 53 * scale,
          width: 196 * scale,
          height: 196 * scale
        },
        {
          type: 'text',
          content: '扫描或长按识别二维码',
          fontSize: 14 * scale,
          color: '#ffffff',
          top: 342 * scale,
          left: 80 * scale
        }
      ]
    }
  }

  /**
   * @param {any} title  商品标题
   * @param {any} goodsCode 商品货号
   * @param {any} goodsSize 商品尺码
   * @param {any} image 商品图片
   * @returns
   * @memberof ImageExample
   */
  proGood(title, goodsCode, goodsSize, image) {
    const padding = 15 // 图片padding
    let posWidth = 300 // 图片默认宽度
    let posHeight = 385 // 图片默认宽度
    let scale = 1.5
    return {
      width: posWidth * scale,
      height: posHeight * scale,
      clear: true,
      views: [
        {
          type: 'rect',
          background: '#ffffff',
          top: 0,
          left: 0,
          width: posWidth * scale,
          height: posHeight * scale
        },
        {
          type: 'text',
          content: title,
          fontSize: 15 * scale,
          bolder: true,
          top: padding * scale,
          left: padding * scale,
          width: 270 * scale, // 大于270换行
          breakWord: true,
          MaxLineNumber: 2,
          lineHeight: 20 * scale
        },
        {
          type: 'text',
          content: `商品款号: ${goodsCode}`,
          fontSize: 12 * scale,
          top: (padding + 40) * scale,
          left: padding * scale,
          width: 270 * scale, // 大于540换行
          MaxLineNumber: 1 // 最多两行
        },
        {
          type: 'text',
          content: `尺码/规格: ${goodsSize}`,
          fontSize: 12 * scale,
          top: (padding + 60) * scale,
          left: padding * scale,
          width: 270 * scale, // 大于540换行
          MaxLineNumber: 1 // 最多两行
        },
        {
          // 海报图
          type: 'image',
          url: image,
          top: 100 * scale,
          width: 270 * scale,
          height: 270 * scale,
          left: padding * scale
        }
      ]
    }
  }
}
